
package Javaa.Base;

//create an example of using List class

import java.util.ArrayList;
import java.util.List;  
public class ListExample {
    public static void main(String[] args) {
        // Create a List of String type
        List<String> fruits = new ArrayList<>();

        // Add elements to the List
        fruits.add("Apple");
        fruits.add("Banana");
        fruits.add("Orange");

        // Access elements from the List    
        System.out.println("First fruit: " + fruits.get(0));

        // Iterate through the List
        System.out.println("All fruits:");
        for (String fruit : fruits) {
            System.out.println(fruit);
        }

        // Remove an element from the List
        fruits.remove("Banana");
        System.out.println("After removing Banana: " + fruits);
    }
}